package com.ganlinux.pangoo.dao.model;

import com.ganlinux.pangoo.dao.basemodel.BaseRecomendedFootmarks;
import com.ganlinux.pangoo.entity.FootPrintRecommendedSimpleInfoBean;
import com.ganlinux.pangoo.entity.FootPrintSimpleInfoBean;
import com.ganlinux.pangoo.entity.response.RspFootPrintRecommendedListData;
import com.ganlinux.pangoo.entity.response.RspFootPrintSimpleInfoListData;
import com.ganlinux.pangoo.tools.AppUtil;
import com.ganlinux.pangoo.tools.ConstantUtil;
import com.jfinal.plugin.activerecord.Page;

import java.util.ArrayList;
import java.util.List;

/**
 * Generated by JFinal.
 */
@SuppressWarnings("serial")
public class RecomendedFootmarks extends BaseRecomendedFootmarks<RecomendedFootmarks> {
	public static final RecomendedFootmarks dao = new RecomendedFootmarks().dao();

	//获取行程概况列表
	public RspFootPrintRecommendedListData getFootTravelSimpleinfoList(String pin, int page, int pagesize) {
		RspFootPrintRecommendedListData rspGetUsersTravelData = new RspFootPrintRecommendedListData();
		List<FootPrintRecommendedSimpleInfoBean> travelSimpleBeans = new ArrayList<FootPrintRecommendedSimpleInfoBean>();
		//		List<UserFootMarkList> usersTravels;
		String selectString = "from recomended_footmarks order by recommended_time desc";
		Page<RecomendedFootmarks> results = paginate(page, pagesize, "select *", selectString);
		List<RecomendedFootmarks> usersTravels = results.getList();
		int size = usersTravels.size();
		for (int i = 0; i < size; i++) {
			RecomendedFootmarks currentUserFootMarkList = usersTravels.get(i);

			FootPrintRecommendedSimpleInfoBean footPrintSimpleInfoBean = (FootPrintRecommendedSimpleInfoBean) UserFootmarkList.dao.getFootPrintSimpleInfoBean(currentUserFootMarkList.getPin(),currentUserFootMarkList.getFootmarkid());
			footPrintSimpleInfoBean.setRecommendedTime(currentUserFootMarkList.getRecommendedTime());
			footPrintSimpleInfoBean.setUpvoteString(currentUserFootMarkList.getUpvoteCnt()+"个赞");
			travelSimpleBeans.add(footPrintSimpleInfoBean);

		}
		rspGetUsersTravelData.setFootPrintRecommendedSimpleInfoBeanList(travelSimpleBeans);
		rspGetUsersTravelData.setPageIndex(results.getPageNumber());
		rspGetUsersTravelData.setTotal(results.getTotalRow());
		rspGetUsersTravelData.setTotalPage(results.getTotalPage());
		return rspGetUsersTravelData;

	}
}
